package com.yanqu.road.logic.redis;

import com.yanqu.road.utils.string.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import redis.clients.jedis.Tuple;

import java.util.HashSet;
import java.util.Set;

/**
 * 获取区服用户人数
 * @Author wpj
 * @Date 2020/11/14
 */
public class RedisServerRegisterPlayerNumHelper {
    private static Logger logger = LogManager.getLogger(RedisServerRegisterPlayerNumHelper.class.getName());

    public static void setRegisterNum(long serverId, int num) {
        RedisManger.getRedisUtil().zadd(RedisKeyDefineHelper.getServerRegisterNumKey(), num, serverId +"");
    }

    public static Set<Tuple> getRegisterNumSet() {
        Set<Tuple> list = RedisManger.getRedisUtil().zRangeWithScores(RedisKeyDefineHelper.getServerRegisterNumKey(), 0, -1);
        if (list == null) {
            return new HashSet<>();
        } else {
            return list;
        }
    }
}
